﻿/*-----------------------------------------------------------------------
											js for Post.aspx
------------------------------------------------------------------------*/
var Post = function() {
	var _ajaxOpts = {
		type: "post",
		cache: false,
		dataType: 'json',
		contentType: 'application/json;charset=utf-8'
	};
	var _delCallback = function(msg, context) {
		msg = $.evalJSON(msg);
		if (msg.IsOk) {
			alert(msg.Body);
			//do some other action
		} else {
			alert(msg.Body);
		};
		//url redirection
		if (msg.Context.url) {
			location.href = msg.Context.url;
		};
	};
	return {
		ID: null,
		Init: function(opts) {
			Post.ID = opts.id;
			$("#btnDelete").click(function() {
				Post.Delete();
				return false;
			});
		}, //endof Init
		Delete: function() {
			if (!window.confirm("确认删除么?")) return;
			var data = {};
			data.id = Post.ID;
			data.action = "delete";
			WebForm_DoCallback('__Page', $.toJSON(data), _delCallback, 'post', null, false);
		} //endof Delete
	};
} ();